home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / amos-tools / eaissue3a / text / r_encrypter.asc < prev    next >
Encoding:
Text File  |  1996-07-13  |  5.9 KB  |  162 lines

  1. ü
  2.                               Encrypter Routine
  3.                               ~~~~~~~~~~~~~~~~~
  4. ù
  5.         So what exactly does an encrypter routine do? Well, basically it
  6.     disguises one piece of code into another, so that when it is read into
  7.     a binary editor, or a word processor, then you would produce some
  8.     strange effects on-screen, yet when untangled with the right
  9.     procedure, it will come out of the other end perfectly entact.
  10.     
  11. þ
  12.         There are several different kinds of encrypter used. The first,
  13.     and maybe the most difficult, is for the computer to recognise certain
  14.     words and phrases in the text, and replace them with a combination of
  15.     characters, which may not be true ASCII. This can also be called a
  16.     cruncher, but we are not discussing that particular subject. A more
  17.     easier kind of encrypter, is to simply swap the values of each
  18.     character around. This is an extremely simple task, and can fool
  19.     anybody for a brief amount of time, unless you know the text is
  20.     encrypted, and you are trying to uncrunch it. This is done by creating
  21.     a table of possible characters, up to 255, and assigning them with a
  22.     number up to 255, so that each of the different characters have a
  23.     different number, but not necesarilly in order. Your list could look a
  24. ÿ
  25. þ
  26.     bit like this :
  27.     
  28.     
  29. û
  30.                                     A = 4
  31.                                    B = 200
  32.                                     C = 19
  33.                                  D = 128 Etc.
  34.     
  35.     
  36. þ
  37.         If you are using just a few letters of the alphabet, or maybe all
  38.     the letters and numbers, then you could always assign more than one
  39.     number to a particular letter, to make unpacking even more complicated
  40.     unless you have the right program to uncrunch it with.
  41.     
  42.     
  43. ý
  44.         One simple way of crunching a piece of text, is if you type out an
  45.     AMOS program similar to the one below, remembering that the below
  46.     version is only a brief example of how the system works. The easiest
  47.     method to encrypt is :
  48.     
  49. ÿ
  50. û
  51.         ' Quick Encryption program.
  52.     
  53.         ' This program will only encrypt 9 letters of any piece of text.
  54.         ' These are a-h, and CHR$(10), a character string VITAL to the
  55.         ' ASCII System. Characters are in lower case.
  56.     
  57.         Do
  58.            F$=Fsel$("","","Select the SOURCE file","to Encrypt")
  59.            G$=Fsel$("","","Select DEST file")
  60.     
  61.            Open In 1,F$ : Reserve As Data 10,Lof(1)
  62.            Reserve As Data 11,Lof(1)
  63.            Close : Bload F$,10 : Rem Load in all of source file
  64.     
  65.            ' Now for the Loop
  66.     
  67.            LE=0
  68.     
  69.            Repeat
  70.               P=Peek(Start(10)+LE)
  71. ÿ
  72. û
  73.               If P>96 and P<105
  74.                  If P=97 : CHAR=2 : Print "Changed Value" : End If
  75.                  If P=98 : CHAR=5 : Print "Changed Value" : End If
  76.                  If P=99 : CHAR=1 : Print "Changed Value" : End If
  77.                  If P=100 : CHAR=4 : Print "Changed Value" : End If
  78.                  If P=101 : CHAR=3 : Print "Changed Value" : End If
  79.                  If P=102 : CHAR=8 : Print "Changed Value" : End If
  80.                  If P=103 : CHAR=6 : Print "Changed Value" : End If
  81.                  If P=104 : CHAR=7 : Print "Changed Value" : End If
  82.               Else
  83.                  CHAR=P
  84.               End If
  85.     
  86.               If P=10 : CHAR=252 : Print "Changed CHR$(10)" : End If
  87.     
  88.               Poke Start(11)+LE,CHAR
  89.               Inc LE
  90.            Until LE>Length(10)
  91.     
  92.            Bsave G$,Start(11) To Start(11)+Length(11)
  93. ÿ
  94. û
  95.            Erase 10 : Erase 11 : Cls
  96.         Loop
  97.     
  98. þ
  99.         The above program is only a simple version, and will only encrypt
  100.     the letters a - h, along with CHR$(10), a character extremely vital to
  101.     the working of ASCII. With this character disabled, the text viewer
  102.     will place all characters onto one line. Remeber, that the encrypter
  103.     is case sensitive, and you will have to change the values for the
  104.     upper and lower case versions.
  105.     
  106. ý
  107.         To un-encrypt the program, simply change the IF... ENDIF
  108.     statements around to read :
  109.     
  110. û
  111.            Repeat
  112.               P=Peek(Start(10)+LE)
  113.               If P>0 and P<9
  114.                  If P=2 : CHAR=97 : Print "Changed Value" : End If
  115.                  If P=5 : CHAR=98 : Print "Changed Value" : End If
  116.                  If P=1 : CHAR=99 : Print "Changed Value" : End If
  117.                  If P=4 : CHAR=100 : Print "Changed Value" : End If
  118. ÿ
  119. û
  120.                  If P=3 : CHAR=101 : Print "Changed Value" : End If
  121.                  If P=8 : CHAR=102 : Print "Changed Value" : End If
  122.                  If P=6 : CHAR=103 : Print "Changed Value" : End If
  123.                  If P=7 : CHAR=104 : Print "Changed Value" : End If
  124.               Else
  125.                  CHAR=P
  126.               End If
  127.     
  128.               If P=252 : CHAR=10 : Print "Changed CHR$(10)" : End If
  129.     
  130.               Poke Start(11)+LE,CHAR
  131.               Inc LE
  132.            Until LE>Length(10)
  133.     
  134. ú
  135.         One problem which you might encounter using this system, is the
  136.     fact that the computer will try to change the wrong kind of
  137.     characters, hence the need to account for ALL possible characters. For
  138.     example, in the above programs I have only used a limited number of
  139.     codes, so if a CHR$(5) is found for example, in the decryption, it
  140.     will be changed to the value that CHR$(5) should be, even though the
  141. ÿ
  142. ú
  143.     decrypter didn't change it in the first place.
  144.     
  145. ø
  146.         Well, I think that is all I can tell you really, apart from the
  147.     fact that I will create a demonstration program to crunch a text file,
  148.     using the characters a-z and A-Z, and I shall leave you with the
  149.     challenge of creating the decrypter !!
  150.     
  151. ü
  152.         Happy AMOS-ing, and if you wish me to cover other subjects, such
  153.     as multi-encryption, then why not drop me a line at the Mushroom PD
  154.     address with a letter demanding I do so !!
  155.     
  156. ú
  157.     [Andrew "Mushroom" Kellett]
  158.     
  159. ÷
  160. EOF
  161.  
  162.